import type { 
  IQuery, 
  AsyncDataResult,
  SelectOneRecordParams,
  SelectRecordsParams,
  SelectJoinRecordParams
} from '../../types'
import { HttpClient } from '../../HttpClient'

export class QueryAPI implements IQuery {
  private httpClient: HttpClient

  constructor(httpClient: HttpClient) {
    this.httpClient = httpClient
  }

  public async selectOne(params: SelectOneRecordParams): AsyncDataResult {
    return await this.httpClient.request<SelectOneRecordParams>('select_one_record', params)
  }

  public async select(params: SelectRecordsParams): AsyncDataResult {
    return await this.httpClient.request<SelectOneRecordParams>('select_records', params)
  }

  public async selectJoin(params: SelectJoinRecordParams): AsyncDataResult {
    return await this.httpClient.request<SelectJoinRecordParams>('select_join', params)
  }
}
